package factory.abstractFactory;

//手机产品接口
interface PhoneProduct {
    void call();

    void sendSMS();
}

//华为手机
class HuaweiPhone implements PhoneProduct {
    @Override
    public void call() {
        System.out.println("华为手机打电话");
    }

    @Override
    public void sendSMS() {
        System.out.println("华为手机发短信");
    }
}

//小米手机
class XiaomiPhone implements PhoneProduct {
    @Override
    public void call() {
        System.out.println("小米手机打电话");
    }

    @Override
    public void sendSMS() {
        System.out.println("小米手机发短信");
    }
}

//路由器产品接口
interface RouterProduct {
    void openWIFI();

    void closeWIFI();
}

//华为路由器
class HuaweiRouter implements RouterProduct{
    @Override
    public void openWIFI() {
        System.out.println("打开华为路由器WIFI");
    }

    @Override
    public void closeWIFI() {
        System.out.println("打开华为路由器WIFI");
    }
}

//小米路由器
class XiaomiRouter implements RouterProduct {
    @Override
    public void openWIFI() {
        System.out.println("打开小米路由器WIFI");
    }

    @Override
    public void closeWIFI() {
        System.out.println("关闭小米路由器WIFI");
    }
}

//抽象产品工厂
interface ProductFactory {
    //生产手机
    PhoneProduct phoneProduce();

    //生产路由器
    RouterProduct routerProduce();
}

//华为工厂
class HuaweiFactory implements ProductFactory {

    @Override
    public PhoneProduct phoneProduce() {
        return new HuaweiPhone();
    }

    @Override
    public RouterProduct routerProduce() {
        return new HuaweiRouter();
    }
}

//小米工厂
class XiaomiFactory implements ProductFactory {
    @Override
    public PhoneProduct phoneProduce() {
        return new XiaomiPhone();
    }

    @Override
    public RouterProduct routerProduce() {
        return new XiaomiRouter();
    }
}

public class Consumer {
    public static void main(String[] args) {
        //小米系列产品
        XiaomiFactory xiaomiFactory = new XiaomiFactory();

        PhoneProduct xiaomiPhoneProduct = xiaomiFactory.phoneProduce();
        xiaomiPhoneProduct.call();          //小米手机打电话
        xiaomiPhoneProduct.sendSMS();       //小米手机发短信

        RouterProduct xiaomiRouterProduct = xiaomiFactory.routerProduce();
        xiaomiRouterProduct.openWIFI();     //打开小米路由器WIFI
        xiaomiRouterProduct.closeWIFI();    //关闭小米路由器WIFI

        //华为系列产品
        HuaweiFactory huaweiFactory = new HuaweiFactory();

        PhoneProduct huaweiPhoneProduct = huaweiFactory.phoneProduce();
        huaweiPhoneProduct.call();          //华为手机打电话
        huaweiPhoneProduct.sendSMS();       //华为手机发短信

        RouterProduct huaweiRouterProduct = huaweiFactory.routerProduce();
        huaweiRouterProduct.openWIFI();     //打开华为路由器WIFI
        huaweiRouterProduct.closeWIFI();    //打开华为路由器WIFI
    }
}